java 实现黑白棋
public class Reversi extends JFrame implements ActionListener{
JButton jbStart = new JButton("开始游戏");
JButton jbStop = new JButton("结束游戏");
MyPanel panel = new MyPanel();
Container c = this.getContentPane();
int width = Toolkit.getDefaultToolkit().getScreenSize().width;
int height = Toolkit.getDefaultToolkit().getScreenSize().height;
boolean canPlay = false;
boolean isBlack = false;
int count = 0;
int f = 1;
int cntBlack = 0;
int cntWhite = 0;
int reversi[][] = new int[9][9];
public Reversi() {
Init();
addListener();
}
public void Init() {
this.setTitle("Reversi");
this.setSize(500, 500);
this.setResizable(false);
this.setLayout(null);
this.setVisible(true);
this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);
this.setLocation((width - 500)/2, (height - 500)/2);
jbStart.setBounds(135, 430, 100, 30);
jbStop.setBounds(265, 430, 100, 30);
panel.add(jbStart);
panel.add(jbStop);
panel.setLayout(null);
panel.setSize(500, 500);
c.add(panel);
}
评论